Skip to content

Fix cobertura coverage statistics when filtering packages or targets #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

swhitty
Copy link

@swhitty swhitty commented Sep 28, 2023

Cobertura files include overall coverage statistics on the root <coverage> element of the file. When packages or targets are excluded via --exclude-packages, --exclude-targets these overall statistics are no longer valid. While it is possible to recalculate using the included <line> elements within the file it is much easier if xcc could do this automatically.

<!-- a single file is included with 100% coverage, due to excludes 50% is reported -->
<coverage line-rate="0.5" lines-covered="50" lines-valid="100">
  <sources>
    <source>/Developer/MyProject</source>
  </sources>
  <packages>
    <package name="Developer.MyProject.Sources.Foo" line-rate="1">
      <classes>
        <class name="Developer.MyProject.Sources.Foo.Bar" line-rate="1">
          <lines>
            <line number="7" hits="6"/>
          </lines>
        </class>
     </classes>
  </package>
</coverage>

This PR recalculates the coverage statistics after any filters have been applied so the resulting cobertura files correctly reflect the statistics of the included files and targets.

@swhitty swhitty changed the title Filter update stats Fix cobertura coverage statistics when filtering packages or targets Sep 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant